package com.kedou.sdk.params.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.kedou.sdk.utils.WL;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Administrator on 2017/6/12 0012.
 */

public final class LoginInfo implements Parcelable {

    private String uid;
    private String ticket;
    private int expiresIn;

    public LoginInfo(String uid, String ticket, int expiresIn) {
        this.uid = uid;
        this.ticket = ticket;
        this.expiresIn = expiresIn;
    }

    protected LoginInfo(Parcel in) {
        uid = in.readString();
        ticket = in.readString();
        expiresIn = in.readInt();
    }

    public static final Creator<LoginInfo> CREATOR = new Creator<LoginInfo>() {
        @Override
        public LoginInfo createFromParcel(Parcel in) {
            return new LoginInfo(in);
        }

        @Override
        public LoginInfo[] newArray(int size) {
            return new LoginInfo[size];
        }
    };

    @Override
    public String toString() {
        JSONObject json = new JSONObject();
        try {
            json.put("uid", uid);
            json.put("ticket", ticket);
            json.put("expiresIn", expiresIn);
        } catch (JSONException e) {
            WL.e("LoginInfo", "JSONException --->");
        }
        return json.toString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(uid);
        dest.writeString(ticket);
        dest.writeInt(expiresIn);
    }
}
